package sundun.sharding.mapper;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import sundun.sharding.entity.ImsYesterdayJqxx;

import java.util.List;

/**
 * 昨日警情信息持久层
 *
 * @author gaomeiling
 * @date 2019年5月28日
 */
@Mapper
public interface ImsYesterdayJqxxDao extends BaseMapper<ImsYesterdayJqxx> {






	@Select({" SELECT * FROM ims_yesterday_jqxx  limit 0,10"})
	List<ImsYesterdayJqxx> getOrderAllByPage();


	@Select({" SELECT t1.* FROM ims_yesterday_jqxx t1 WHERE t1.gxdwbh IN ('210203000000', '210202000000') AND t1.bjsj >= '2023-01-01' AND t1.sfdj = '1' AND t1.sfcl = '0'"})
	List<ImsYesterdayJqxx> getOrderAll();

	@Select({"SELECT o.order_no, SUM(i.price * i.count) AS amount",
			"FROM t_order o JOIN t_order_item i ON o.order_no = i.order_no",
			"GROUP BY o.order_no"})
	List<ImsYesterdayJqxx> getOrderAmount();

	@Select({"SELECT t1.* FROM ims_yesterday_jqxx t1 WHERE (LEFT(t1.gxdwbh, 4) = LEFT('210202000000', 4)) AND t1.sfdj = '1' AND t1.sfcl = '0' AND t1.bjsj >= current_date()"})
	List<ImsYesterdayJqxx> getAllJqxx();

	@Select({"SELECT * FROM ims_yesterday_jqxx t1 LEFT JOIN ims_sys_center_org t2 ON t1.gxdwbh = t2.orgCode where  t1.bjsj >= '2021-01-01' and t1.bjsj <= '2022-01-01'  "})
	List<ImsYesterdayJqxx> getAllJqxx1();


	@Select({"SELECT * FROM ims_sys_center_org t1 LEFT JOIN ims_yesterday_jqxx  t2 ON t1.orgCode = t2.gxdwbh where  t2.bjsj >= '2021-01-01' and t2.bjsj <= '2022-01-01'  "})
	List<ImsYesterdayJqxx> getAllJqxx2();



	int insert1(ImsYesterdayJqxx jqxx);

}
